//-------------------------------------------------------------------
//	Copyright (c) 2010-2012  Zhirnov Andrey
//	This file is part of the "UXGEN" project.
//	See copyright notice in "Engine.h".
//-------------------------------------------------------------------

#ifndef _UX_GUI_BASE_H
#define _UX_GUI_BASE_H

#include <Includes.h>
#include "../../Resources/AllResources.h"
#include "../../Systems/Config/CConfig.h"

namespace Engine
{
namespace GUI
{

	
	//
	// GUI Base Object interface
	//

	class IGUIBaseObject
	{
	public:
		virtual void				Free() = 0;
		virtual e_gui_object::type	GetType() const = 0;
		virtual const string &		GetTypeName() const = 0;
	};



	//
	// GUI Object Event Listener interface
	//

	template <typename Message>
	class IGUIObjectEventListener : public IGUIBaseObject
	{
	public:
		virtual bool ProcessMessage(Message &) = 0;
	};



	//
	// GUI Component Style
	//
	
	template <typename Message>
	class IGUIBaseStyle : public IGUIObjectEventListener< Message >
	{
	public:
		virtual bool GetMetaIterator(CMetaSetIterator *&) = 0;

		virtual e_gui_object::type	GetType() const		{ return e_gui_object::STYLE; }
	};
	


	template <typename Message>
	class IGUIEventListener;



	//
	// GUI Widget interface
	//

	template <typename Message>
	class IGUIWidget : public IGUIObjectEventListener<Message>
	{
	public:
		virtual void SetEventListener(IGUIEventListener<Message> *) = 0;
		virtual bool GetMetaIterator(CMetaSetIterator *&) = 0;

		virtual e_gui_object::type	GetType() const		{ return e_gui_object::WIDGET; }
	};



	//
	// GUI Widget Event Listener interface
	//

	template <typename Message>
	class IGUIEventListener
	{
	public:
		virtual void ProcessMessage(Message &) = 0;
		virtual void OnAttach(IGUIWidget<Message> *) = 0;
		virtual void OnDetach(IGUIWidget<Message> *) = 0;
	};



	//
	// GUI Screen interface
	//

	template <	typename Message,
				typename WM	/* widget message type */,
				typename SM /* style message type */ >

	class IGUIScreen : public IGUIObjectEventListener<Message>
	{
	public:
		typedef IGUIWidget< WM >		IGUIWidget;
		typedef IGUIBaseStyle< SM >		IGUIStyle;

	public:
		//virtual void SetParams() = 0;

		virtual void AddWidget(IGUIWidget *) = 0;
		virtual void RemoveWidget(IGUIWidget *) = 0;
		virtual bool GetWidget(const string &, IGUIWidget *&) = 0;
		
		//virtual bool Load(IFilePtr) = 0;
		//virtual bool Load(const char *) = 0;

		virtual e_gui_object::type	GetType() const		{ return e_gui_object::SCREEN; }
	};

//-------------------------------------------------------------------

}	// GUI
}	// Engine

#endif	// _UX_GUI_BASE_H